$(function(){
	if(load_foodAllowance_select) {
		load_foodAllowance_select();
	}
	
	$("#btnOK").click(function() {
		var relationId = $('input:radio[name="relationPerson"]:checked').attr('id');
		var allowanceApply = {};
		allowanceApply.relationId = relationId;
		allowanceApply.relationName = $('input:radio[name="relationPerson"]:checked').attr('relationName');
		allowanceApply.relationCardId = $('input:radio[name="relationPerson"]:checked').attr('relationCardId');
		allowanceApply.relationType = $('input:radio[name="relationPerson"]:checked').attr('relationType');
		allowanceApply.approveStatus = 0;
		allowanceApply.foodAllowanceId = $('#foodAllowance_select').val();
		allowanceApply.allowanceName = getSelectFieldValue('foodAllowance_select', 'foodAllowanceName');
		allowanceApply.allowanceAmount = getSelectFieldValue('foodAllowance_select', 'foodAllowanceAmount');
		
		if(isEmpty(allowanceApply.relationId)) {
			alert('请选择人员');
			return;
		}
		
		
		if(isEmpty(allowanceApply.foodAllowanceId)) {
			alert('请选择补贴标准');
			return;
		}
		
		save_basic(path+'/allowanceApply/save', {allowanceApply:allowanceApply}, function(response) {
			if(response.code=='200') {
				if(hasFileToUpload==false) {
					alert('保存成功');
				}else {
					var options = {  
						url: path+'/accessory/uploadFiles?id='+response.data[0].allowanceApplyId,
						type : "post",  
						dataType : 'json',
						
						//提交前处理 
						beforeSubmit: function() {
						},
						
						//处理完成 
						success: function(response_success) {
							if(response_success.code=='200') {
								alert('保存成功');
							}else {
								alert('文件提交失败');
							}
						}
					};
					
					$('#uploadFileForm').ajaxSubmit(options);
				}
			}else {
				alert('数据提交失败');
			}
		});
	});
});